home *** CD-ROM | disk | FTP | other *** search
Wrap
RRRRWWWWXXXXDDDDRRRRoooossssttttrrrreeeeaaaammmm((((3333CCCC++++++++)))) RRRRWWWWXXXXDDDDRRRRoooossssttttrrrreeeeaaaammmm((((3333CCCC++++++++)))) NNNNaaaammmmeeee RWXDRostream (Unix only) - Rogue Wave library class SSSSyyyynnnnooooppppssssiiiissss #include <rw/xdrstrea.h> XDR xdr; xdrstdio_create(&xdr, stdout, XDR_ENCODE) ; RWXDRostream rw_xdr(&xdr); DDDDeeeessssccccrrrriiiippppttttiiiioooonnnn Class RRRRWWWWXXXXDDDDRRRRoooossssttttrrrreeeeaaaammmm is a portable output stream based on XDR routines. Class RRRRWWWWXXXXDDDDRRRRoooossssttttrrrreeeeaaaammmm encapsulates a portion of the XDR library routines that are used for external data representation. XDR routines allow programmers to describe arbitrary data structures in a machine- independent fashion. Data for remote procedure calls (RPC) are transmitted using XDR routines. Class RRRRWWWWXXXXDDDDRRRRoooossssttttrrrreeeeaaaammmm enables one to output from a stream and encode an XDR structure from a machine representation. Class RRRRWWWWXXXXDDDDRRRRoooossssttttrrrreeeeaaaammmm provides the capability to encode the standard data types and vectors of those data types. An XDR stream must first be created by calling the appropriate creation routine. XDR streams currently exist for encoding/decoding of data to or from standard iostreams and file streams, TCP/IP connections and Unix files, and memory. These creation routines take arguments that are tailored to the specific properties of the stream. After the XDR stream has been created, it can then be used as an argument to the constructor for a RRRRWWWWXXXXDDDDRRRRoooossssttttrrrreeeeaaaammmm object. RRRRWWWWXXXXDDDDRRRRoooossssttttrrrreeeeaaaammmm can be interrogated as to the status of the stream using member functions bbbbaaaadddd(((()))), cccclllleeeeaaaarrrr(((()))), eeeeooooffff(((()))), ffffaaaaiiiillll(((()))), ggggoooooooodddd(((()))), and rrrrddddssssttttaaaatttteeee(((()))). PPPPeeeerrrrssssiiiisssstttteeeennnncccceeee None EEEExxxxaaaammmmpppplllleeee The example that follows is a "writer" program that encodes an XDR structure onto a file stream. The example for class RRRRWWWWXXXXDDDDRRRRiiiissssttttrrrreeeeaaaammmm is the "reader" program that decodes the XDR structures into a machine representation for a data type. The library that supports XDR routines must be linked in. The name of this library is not standard. #include <rw/xdrstrea.h> PPPPaaaaggggeeee 1111 RRRRWWWWXXXXDDDDRRRRoooossssttttrrrreeeeaaaammmm((((3333CCCC++++++++)))) RRRRWWWWXXXXDDDDRRRRoooossssttttrrrreeeeaaaammmm((((3333CCCC++++++++)))) #include <rw/rstream.h> #include <stdio.h> main(){ XDR xdr; FILE* fp = fopen("test","w+"); xdrstdio_create(&xdr, fp, XDR_ENCODE); RWXDRostream rw_xdr(&xdr); for(int i=0; i<10; ++i) rw_xdr << i; // encode integer data fclose(fp); } PPPPuuuubbbblllliiiicccc CCCCoooonnnnssssttttrrrruuuuccccttttoooorrrr RRRRWWWWXXXXDDDDRRRRoooossssttttrrrreeeeaaaammmm(XDR* xp); Initialize a RRRRWWWWXXXXDDDDRRRRoooossssttttrrrreeeeaaaammmm from the XDR structure xxxxpppp. RRRRWWWWXXXXDDDDRRRRoooossssttttrrrreeeeaaaammmm(streambuf*); Initialize RRRRWWWWXXXXDDDDRRRRoooossssttttrrrreeeeaaaammmm with a pointer to ssssttttrrrreeeeaaaammmmbbbbuuuuffff. ssssttttrrrreeeeaaaammmmbbbbuuuuffff must already be allocated. RRRRWWWWXXXXDDDDRRRRoooossssttttrrrreeeeaaaammmm(ostream&); Initialize RRRRWWWWXXXXDDDDRRRRoooossssttttrrrreeeeaaaammmm with an output stream. PPPPuuuubbbblllliiiicccc DDDDeeeessssttttrrrruuuuccccttttoooorrrr virtual ~RRRRWWWWXXXXDDDDRRRRoooossssttttrrrreeeeaaaammmm(); Deallocate previously allocated resources. PPPPuuuubbbblllliiiicccc MMMMeeeemmmmbbbbeeeerrrr FFFFuuuunnnnccccttttiiiioooonnnnssss virtual RWvostream& ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<(const char* s); Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm. Store the character string starting at ssss to the output stream using the XDR format. The character string is expected to be null terminated. virtual RWvostream& ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<(char c); PPPPaaaaggggeeee 2222 RRRRWWWWXXXXDDDDRRRRoooossssttttrrrreeeeaaaammmm((((3333CCCC++++++++)))) RRRRWWWWXXXXDDDDRRRRoooossssttttrrrreeeeaaaammmm((((3333CCCC++++++++)))) Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm. Store the character cccc to the output stream using the XDR format. Note that c is treated as a character, not a number. This member attempts to preserve the symbolic characters values transmitted over the stream. virtual RWvostream& ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<(wchar_t wc); Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm. Store the wide character wwwwcccc to the output stream using the XDR format. Note that wwwwcccc is treated as a character, not a number. virtual RWvostream& ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<(unsigned char c); Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm. Store the unsigned character cccc to the output stream using the XDR format. Note that cccc is treated as a character, not a number. virtual RWvostream& ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<(double d); Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm. Store the ddddoooouuuubbbblllleeee dddd to the output stream using the XDR format. virtual RWvostream& ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<(float f); Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm. Store the ffffllllooooaaaatttt ffff to the output stream using the XDR format. virtual RWvostream& ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<(int i); Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm. Store the integer iiii to the output stream using the XDR format. virtual RWvostream& ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<(unsigned int i); Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm. Store the unsigned integer iiii to the output stream using the XDR format. virtual RWvostream& ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<(long l); PPPPaaaaggggeeee 3333 RRRRWWWWXXXXDDDDRRRRoooossssttttrrrreeeeaaaammmm((((3333CCCC++++++++)))) RRRRWWWWXXXXDDDDRRRRoooossssttttrrrreeeeaaaammmm((((3333CCCC++++++++)))) Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm. Store the lllloooonnnngggg llll to the output stream using the XDR format. virtual RWvostream& ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<(unsigned long l); Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm. Store the unsigned lllloooonnnngggg llll to the output stream using the XDR format. virtual RWvostream& ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<(short s); Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm. Store the sssshhhhoooorrrrtttt ssss to the output stream using the XDR format. virtual RWvostream& ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<((((unsigned short ); Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm. Store the unsigned sssshhhhoooorrrrtttt ssss to the output stream using the XDR format. virtual RWvostream& ppppuuuutttt(char c); Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm. Store the character cccc to the output stream using the XDR format. If the operation fails, it sets the failbit. This member only preserves ASCII numerical codes, not the coresponding character symbol. virtual RWvostream& ppppuuuutttt(unsigned char c); Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm. Store the unsigned character cccc to the output stream using the XDR format. If the operation fails, it sets the failbit. virtual RWvostream& ppppuuuutttt(wchar_t wc); Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm. Store the wide character wwwwcccc to the output stream using the XDR format. If the operation fails, it sets the failbit. virtual RWvostream& ppppuuuutttt(const char* p, size_t N); PPPPaaaaggggeeee 4444 RRRRWWWWXXXXDDDDRRRRoooossssttttrrrreeeeaaaammmm((((3333CCCC++++++++)))) RRRRWWWWXXXXDDDDRRRRoooossssttttrrrreeeeaaaammmm((((3333CCCC++++++++)))) Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm. Store the vector of NNNN characters starting at pppp to the output stream using the XDR format. If the operation fails, it sets the failbit. virtual RWvostream& ppppuuuutttt(const wchar_t* p, size_t N); Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm. Store the vector of NNNN wide characters starting at pppp to the output stream using the XDR format. If the operation fails, it sets the failbit. virtual RWvostream& ppppuuuutttt(const short* p, size_t N); Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm. Store the vector of NNNN sssshhhhoooorrrrtttts starting at pppp to the output stream using the XDR format. If the operation fails, it sets the failbit. virtual RWvostream& ppppuuuutttt(const unsigned short* p, size_t N); Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm. Store the vector of NNNN unsigned sssshhhhoooorrrrtttts starting at pppp to the output stream using the XDR format. If the operation fails, it sets the failbit. virtual RWvostream& ppppuuuutttt(const int* p, size_t N); Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm. Store the vector of NNNN integers starting at pppp to the output stream using the XDR format. If the operation fails, it sets the failbit. virtual RWvostream& ppppuuuutttt(const unsigned int* p, size_t N); Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm. Store the vector of NNNN unsigned integers starting at pppp to the output stream using the XDR format. If the operation fails, it sets the failbit. virtual RWvostream& ppppuuuutttt(const long* p, size_t N); Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm. Store the vector of NNNN lllloooonnnnggggs starting at pppp to the output stream using the XDR format. If the operation fails, it sets the failbit. PPPPaaaaggggeeee 5555 RRRRWWWWXXXXDDDDRRRRoooossssttttrrrreeeeaaaammmm((((3333CCCC++++++++)))) RRRRWWWWXXXXDDDDRRRRoooossssttttrrrreeeeaaaammmm((((3333CCCC++++++++)))) virtual RWvostream& ppppuuuutttt(const unsigned long* p, size_t N); Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm. Store the vector of NNNN unsigned lllloooonnnnggggs starting at pppp to the output stream using the XDR format. If the operation fails, it sets the failbit. virtual RWvostream& ppppuuuutttt(const float* p, size_t N); Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm. Store the vector of NNNN ffffllllooooaaaatttts starting at pppp to the output stream using the XDR format. If the operation fails, it sets the failbit. virtual RWvostream& ppppuuuutttt(const double* p, size_t N); Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm. Store the vector of NNNN ddddoooouuuubbbblllleeees starting at pppp to the output stream using the XDR format. If the operation fails, it sets the failbit. Virtual RWXDRostream& fffflllluuuusssshhhh(); Send the contents of the stream buffer to output immediately. Virtual RWXDRostream& ppppuuuuttttSSSSttttrrrriiiinnnngggg(const char*s, size_t N); Store the character string for retrieval by RRRRWWWWXXXXDDDDRRRRiiiissssttttrrrreeeeaaaammmm::::::::ggggeeeettttSSSSttttrrrriiiinnnngggg. PPPPaaaaggggeeee 6666